package com.bosssoft.user.permission.center.serve.dao.mapper;

import com.bosssoft.user.permission.center.serve.dao.entity.Role;
import com.bosssoft.user.permission.center.serve.pojo.vo.RoleVO;

import common.annotation.AutoFill;
import common.annotation.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper {

    List<RoleVO> searchRoleList(@Param("companyList") List<Long> companyList, @Param("name") String name);

    @AutoFill(OperationType.INSERT)
    @Insert("INSERT INTO basic_role(id, name, code, remark, org_id, tenant_id,company_id, created_by,created_time, updated_by,  updated_time, status) values(#{id},#{name},#{code},#{remark}, #{orgId},#{tenantId} ,#{companyId}, #{createdBy},#{createdTime}, #{updatedBy}, #{updatedTime}, #{status}) ")
    Boolean insert(Role role);

    @AutoFill(OperationType.UPDATE)
    @Update("UPDATE basic_role SET name=#{name}, code=#{code}, remark=#{remark},updated_by=#{updatedBy}, updated_time=#{updatedTime}, status=#{status} WHERE id=#{id}")
    Boolean update(Role role);



    Boolean batchDeleteRoles(@Param("ids") List<Long> ids);

    @Select("SELECT count(*) FROM basic_role where code = #{code}")
    Integer checkRoleCode(@Param("code") String code);


    /**
     * 描述: 根据id和code检查当前code是否可用
     * 作者: lljm
     * 日期: 2024/6/15
     */
    Integer checkRoleCodeAndRoleId(@Param("code") String code, @Param("roleId") Long roleId);
}
